<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script src="/static/echarts.js"></script>
    <title>Document</title>
</head>
<body>
hello world
<hr>
{{ mydata.math }}
<hr>
{{ mydata.english }}
<hr>
{{ mydata.chinese }}
<hr>
<div id="main" style="width: 600px;height:400px;"></div>
    <script type="text/javascript" charset="UTF-8">
        // 基于准备好的dom，初始化echarts实例
        var myChart = echarts.init(document.getElementById('main'));
        var name={{ mydata.stu_no|safe }};
        // 变量使用safe过滤器，避免出现单引号编码无法正常显示问题
        // 指定图表的配置项和数据
        var option = {
            title: {
                text: 'Student 成绩总分排序(降序)'
            },
            tooltip: {},
            legend: {
                data:['成绩']
            },
            xAxis: {
                type: 'category',
                data:  name.split(',')
                // 识别为字符串，将字符串转为数组
            },
            yAxis: {},
            series: [{
                name: '成绩',
                type: 'bar',
                data: {{ mydata.total }}
            }]
        };



        // 使用刚指定的配置项和数据显示图表。
        myChart.setOption(option);
    </script>
<div id="main1" style="width: 600px;height:400px;"></div>
    <script type="text/javascript" charset="UTF-8">
        // 基于准备好的dom，初始化echarts实例
        var tonhji = {{ mydata.tongji.0|safe }}
        var tongji2 = {{ mydata.tongji.1|safe }}
        var myChart = echarts.init(document.getElementById('main1'));
               var option2 = {

    title: {
        text: '成绩比列图',
        subtext: '三年二班',
        left: 'center'
    },
    tooltip: {
        trigger: 'item'
    },
    legend: {
        orient: 'vertical',
        left: 'left',
    },
    series: [
        {
            name: '成绩统计',
            type: 'pie',
            radius: '50%',
            data: [
                tonhji,
                tongji2
            ],
            emphasis: {
                itemStyle: {
                    shadowBlur: 10,
                    shadowOffsetX: 0,
                    shadowColor: 'rgba(0, 0, 0, 0.5)'
                }
            }
        }
    ]
        };
        myChart.setOption(option2);
    </script>
<div id="main3" style="width: 600px;height:400px;"></div>
    <script type="text/javascript" charset="UTF-8">
        // 基于准备好的dom，初始化echarts实例
        var myChart = echarts.init(document.getElementById('main3'));
        var name={{ mydata.stu_no|safe }};
        var math = {{ mydata.math|safe }};
        var chinese = {{ mydata.chinese|safe }};
        var english = {{ mydata.english|safe }};
        var a_60 = 0
        var a_80=0
        var a_100=0
        for(var i=0;i<math.length;i++){
            if(math[i]<60){
                 a_60=a_60+1
            }
            else if(60<=math[i]&& math[i]<80){
                a_80=a_80+1
            }
            else {
                a_100=a_100+1
            };
        }
        var b_60 = 0
        var b_80=0
        var b_100=0
        for(var i=0;i<chinese.length;i++){
            if(chinese[i]<60){
                 b_60=b_60+1
            }
            else if(60<=chinese[i]&& chinese[i]<80){
                b_80=b_80+1
            }
            else {
                b_100=b_100+1
            };
        }
        var c_60 = 0
        var c_80=0
        var c_100=0
        for(var i=0;i<english.length;i++){
            if(english[i]<60){
                 c_60=c_60+1
            }
            else if(60<=english[i]&& english[i]<80){
                c_80=c_80+1
            }
            else {
                c_100=c_100+1
            };
        }
        console.log(a_80)
        // 变量使用safe过滤器，避免出现单引号编码无法正常显示问题
        // 指定图表的配置项和数据
        var option = {
            title: {
                text: '三年二班各科成绩分布'
            },
    legend: {},
    tooltip: {},
    dataset: {
        dimensions: ['product', '数学', '语文', '英语'],
        source: [
            {product: '低于60分', '数学': a_60, '语文':    b_60, '英语': c_60},
            {product: '高于60小于80', '数学': a_80, '语文': b_80, '英语': c_80},
            {product: '高于80', '数学': a_100, '语文': b_100, '英语': c_100},
        ]
    },
    xAxis: {type: 'category'},
    yAxis: {},
    // Declare several bar series, each will be mapped
    // to a column of dataset.source by default.
    series: [
        {type: 'bar'},
        {type: 'bar'},
        {type: 'bar'}
    ]
        };



        // 使用刚指定的配置项和数据显示图表。
        myChart.setOption(option);
    </script>
</body>
</html>